﻿using NMortgage.UI.Converters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Globalization;
using System.Resources;
using NMortgage.UI.Tests.Converters;
using System.Windows;

namespace NMortgage.UI.Tests
{
    
    
    /// <summary>
    ///This is a test class for XNameToImageResourceConverterTest and is intended
    ///to contain all XNameToImageResourceConverterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class XNameToImageResourceConverterTest
    {
        private XNameToImageResourceConverter Subject { get; set; }
        [TestInitialize]
        public void Initialize()
        {
            Subject = new XNameToImageResourceConverter();
        }
        [TestMethod]
        public void Returns_Null_If_Element_Is_Null()
        {
            // Arrange
            // Act
            var actual = Subject.Convert(null, null, Properties.Resources.ResourceManager, null);
            // Assert
            Assert.IsNull(actual);
        }
        [TestMethod]
        public void Returns_Null_If_ResourceManager_Is_Null()
        {
            // Arrange
            // Act
            var actual = Subject.Convert(ResourcesEnum.WithoutResource, null, null, null);
            // Assert
            Assert.IsNull(actual);
        }
        [TestMethod]
        public void Reads_Resource_String_From_Resources_By_Convention()
        {
            // Arrange
            var expected = Properties.Resources.Name_Image;
            // Act
            var actual = Subject.Convert(new FrameworkElement() { Name = "Name" }, null, Properties.Resources.ResourceManager,
                                         CultureInfo.CurrentCulture);
            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Returns_Null_When_Value_Is_Null()
        {
            // Arrange
            // Act
            var actual = Subject.Convert(null, null, null, CultureInfo.CurrentCulture);
            // Assert
            Assert.IsNull(actual);
        }
        [TestMethod]
        public void ConvertBack_Is_Not_Supported()
        {
            // Arrange
            var expected = DependencyProperty.UnsetValue;
            // Act
            var actual = Subject.ConvertBack("anything", null, null, null);
            // Assert
            Assert.AreEqual(expected, actual);
        }
   
    }
}
